#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cerr<<"$"<<#x<<"="<<x<<"\n"
void exe(){
    int n,m,L,V;
    cin>>n>>m>>L>>V;
    int d[n],v[n],a[n],ansa=0;
    int p[m];
    for(int i=0;i<n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        int k=lower_bound(p,p+m,d[i])-p;
        for(int j=k;j<m;j++){
            if(v[i]*v[i]+2*a[i]*(p[j]-d[i])<=0)break;
            if(v[i]*v[i]+2*a[i]*(p[j]-d[i])>V*V){
                ansa++;
                break;
            }
        }
    }
    cout<<ansa<<" "<<m-1<<"\n";
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)exe();
    return 0;
}
